#!/usr/bin/env bash

version=$1
if [ -z "$version" ]; then
   echo "Usage: log-entires VERSION" >&2
   echo "Example: cat Changelog | log-entries 1.0.1" >&2
   exit 1
fi

awk "
BEGIN {
   start = \"^v\" \"$version\"
}

\$0 ~ start {
   while ( getline ) {
      if ( \$0 ~ /^v[0-9]/ )
         exit
      if ( \$0 ~ /^\$/ )
         continue
      
      print
   }
}
"

exit $?
